********************************************************************************		
************** Benchmark regressions with increase-per-worker measure **********
********************************************************************************
clear
use "BHPS_merged.dta"

do "ML programs to add model statistics.do"
	
	
********** Multilevel models for increase-per-worker measure of China shock ********
	* global with individual-level control variables
	global controls "i.education i.male c.age_cent##c.age_cent i.bornelsewhere2 i.parentsbornelsewhere"


*** EU support

	*** increase-per-worker measure
	global tradevar "real_ADH_imp_CH_d_eu_nl"		

	* without controls
	mixed D_EUsupport c.LDV_EUsupport##i.year ///
		$tradevar ///
		$controls i.ID_NUTS1xYear ///
		if (year==2006 | year==2002) ///
		|| ID_NUTS3: || ID_NUTS3xYear: , stddeviations 

		add_scalars_mixed_2level
		sum D_EUsupport $tradevar if e(sample)

		eststo EU1_ADH		

	* with controls: employment share				
	mixed D_EUsupport c.LDV_EUsupport##i.year ///
		$tradevar ///
		emplsh_manufact_1998 ///
		$controls i.ID_NUTS1xYear ///
		if (year==2006 | year==2002) ///
		|| ID_NUTS3: || ID_NUTS3xYear: , stddeviations 

		add_scalars_mixed_2level
		sum D_EUsupport $tradevar if e(sample)

		eststo EU2_ADH	

	* with all controls				
	mixed D_EUsupport c.LDV_EUsupport##i.year ///
		$tradevar ///
		emplsh_manufact_1998 pop_sharenonUK pop_sharenonUK_d_eu ///
		$controls i.ID_NUTS1xYear  ///
		if (year==2006 | year==2002) ///
		|| ID_NUTS3: || ID_NUTS3xYear: || ID_lad13xyear: , stddeviations

		add_scalars_mixed_2level
		sum D_EUsupport $tradevar if e(sample)

		eststo EU3_ADH	

	* with all controls & NUTS2-year FE						
	mixed D_EUsupport c.LDV_EUsupport##i.year ///
		$tradevar ///
		emplsh_manufact_1998 pop_sharenonUK pop_sharenonUK_d_eu ///
		$controls i.ID_NUTS2xYear  ///
		if (year==2006 | year==2002) ///
		|| ID_NUTS3: || ID_NUTS3xYear: || ID_lad13xyear: , stddeviations

		add_scalars_mixed_2level
		sum D_EUsupport $tradevar if e(sample)

		eststo EU4_ADH		
					
	* write table
	esttab EU1_ADH EU2_ADH EU3_ADH EU4_ADH using "ML regressions incrperworker_EUsupport.rtf", b(a2) se(a2) star(+ 0.10 * 0.05 ** 0.01 *** 0.001) ///
		scalars(group1N group2N group3N ri1_std ri2_std ri3_std icc1 icc2 icc3 bic) varwidth(30) nogaps compress ///
		drop(0.male 0.education 0.bornelsewhere2 0.parentsbornelsewhere 2002.year *.ID_NUTS1xYear *.ID_NUTS2xYear lnsig_e:_cons) /// 
		label replace transform(ln*: exp(@) exp(@)) 		



	*** Nationalism
	global tradevar "real_ADH_imp_CH_d3_nl"

	* without controls
	mixed D3_nationalism L3.nationalism ///
		$tradevar ///
		$controls i.ID_NUTS1xYear ///
		if (year==2008 | year==2005 | year==2002) ///
		|| ID_NUTS3: || ID_NUTS3xYear: , stddeviations 

		add_scalars_mixed_2level
		sum D3_nationalism $tradevar if e(sample)				

		eststo NAT1_ADH	

	* with controls: employment share				
	mixed D3_nationalism L3.nationalism ///
		$tradevar ///
		emplsh_manufact_1998 ///
		$controls i.ID_NUTS1xYear ///
		if (year==2008 | year==2005 | year==2002) ///
		|| ID_NUTS3: || ID_NUTS3xYear: , stddeviations 

		add_scalars_mixed_2level
		sum D3_nationalism $tradevar if e(sample)				

		eststo NAT2_ADH	

	* with all controls				
	mixed D3_nationalism L3.nationalism  ///
		$tradevar ///
		emplsh_manufact_1998 pop_sharenonUK pop_sharenonUK_d_nat ///
		$controls i.ID_NUTS1xYear  ///
		if (year==2008 | year==2005 | year==2002) ///
		|| ID_NUTS3: || ID_NUTS3xYear: || ID_lad13xyear: , stddeviations reml

		add_scalars_mixed_3level
		sum D3_nationalism $tradevar if e(sample)				
						
		eststo NAT3_ADH	

	* with all controls & NUTS2-year FE						
	mixed D3_nationalism L3.nationalism  ///
		$tradevar ///
		emplsh_manufact_1998 pop_sharenonUK pop_sharenonUK_d_nat ///
		$controls i.ID_NUTS2xYear  ///
		if (year==2008 | year==2005 | year==2002) ///
		|| ID_NUTS3: || ID_NUTS3xYear: || ID_lad13xyear: , stddeviations

		add_scalars_mixed_3level
		sum D3_nationalism $tradevar if e(sample)				

		eststo NAT4_ADH				
					
	* write table
	esttab NAT1_ADH NAT2_ADH NAT3_ADH NAT4_ADH using "ML regressions incrperworker_Nationalism.rtf", b(a2) se(a2) star(+ 0.10 * 0.05 ** 0.01 *** 0.001) ///
		scalars(group1N group2N group3N ri1_std ri2_std ri3_std icc1 icc2 icc3 bic) varwidth(30) nogaps compress ///
		drop(0.male 0.education 0.bornelsewhere2 0.parentsbornelsewhere *.ID_NUTS1xYear *.ID_NUTS2xYear lnsig_e:_cons) /// 	
		label replace transform(ln*: exp(@) exp(@)) 
					